VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form frmImport 
   BackColor       =   &H00FFFFFF&
   Caption         =   "Import Commodities"
   ClientHeight    =   2565
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5670
   Icon            =   "frmImport.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   ScaleHeight     =   2565
   ScaleWidth      =   5670
   StartUpPosition =   1  'CenterOwner
   Begin MSComDlg.CommonDialog dlgCommodity 
      Left            =   240
      Top             =   2040
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.CommandButton cmdClose 
      Appearance      =   0  'Flat
      BackColor       =   &H00E0E0E0&
      Caption         =   "Close"
      Height          =   315
      Left            =   3240
      MaskColor       =   &H0080C0FF&
      Style           =   1  'Graphical
      TabIndex        =   5
      Top             =   2100
      UseMaskColor    =   -1  'True
      Width           =   1215
   End
   Begin VB.CommandButton cmdImport 
      Appearance      =   0  'Flat
      BackColor       =   &H00E0E0E0&
      Caption         =   "Import"
      Height          =   315
      Left            =   1200
      MaskColor       =   &H0080C0FF&
      Style           =   1  'Graphical
      TabIndex        =   4
      Top             =   2100
      UseMaskColor    =   -1  'True
      Width           =   1215
   End
   Begin VB.Frame Frame1 
      BackColor       =   &H00FFFFFF&
      Caption         =   "Select Type and Filename"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000080FF&
      Height          =   1815
      Left            =   120
      TabIndex        =   6
      Top             =   120
      Width           =   5415
      Begin VB.CommandButton cmdBrowse 
         BackColor       =   &H00E0E0E0&
         Caption         =   "..."
         BeginProperty Font 
            Name            =   "Arial Black"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   285
         Left            =   4680
         Style           =   1  'Graphical
         TabIndex        =   3
         Top             =   840
         Width           =   375
      End
      Begin VB.TextBox txtImportFilename 
         Height          =   285
         Left            =   1320
         TabIndex        =   2
         Top             =   840
         Width           =   3255
      End
      Begin VB.OptionButton optAppend 
         BackColor       =   &H00FFFFFF&
         Caption         =   "Append"
         Height          =   255
         Left            =   1680
         TabIndex        =   0
         Top             =   360
         Width           =   975
      End
      Begin VB.OptionButton optOverwrite 
         BackColor       =   &H00FFFFFF&
         Caption         =   "Overwrite"
         Height          =   255
         Left            =   3240
         TabIndex        =   1
         Top             =   360
         Width           =   1095
      End
      Begin VB.Label lblStatus 
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H00C00000&
         Height          =   255
         Left            =   960
         TabIndex        =   14
         Top             =   1320
         Width           =   975
      End
      Begin VB.Label lblImported 
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H0000C000&
         Height          =   255
         Left            =   2790
         TabIndex        =   13
         Top             =   1320
         Width           =   855
      End
      Begin VB.Label lblErrors 
         BackColor       =   &H00FFFFFF&
         ForeColor       =   &H000000C0&
         Height          =   255
         Left            =   4260
         TabIndex        =   12
         Top             =   1320
         Width           =   855
      End
      Begin VB.Label lblStat 
         BackColor       =   &H00FFFFFF&
         Caption         =   "Status:"
         Height          =   255
         Left            =   360
         TabIndex        =   11
         Top             =   1320
         Width           =   495
      End
      Begin VB.Label lblImp 
         Appearance      =   0  'Flat
         BackColor       =   &H00FFFFFF&
         Caption         =   "Imported:"
         ForeColor       =   &H80000008&
         Height          =   255
         Left            =   2040
         TabIndex        =   10
         Top             =   1320
         Width           =   735
      End
      Begin VB.Label lblErr 
         BackColor       =   &H00FFFFFF&
         Caption         =   "Errors:"
         Height          =   255
         Left            =   3720
         TabIndex        =   9
         Top             =   1320
         Width           =   495
      End
      Begin VB.Label Label1 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00FFFFFF&
         Caption         =   "Type:"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   360
         TabIndex        =   8
         Top             =   360
         Width           =   855
      End
      Begin VB.Label Label37 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00FFFFFF&
         Caption         =   "Filename:"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   360
         TabIndex        =   7
         Top             =   900
         Width           =   855
      End
   End
End
Attribute VB_Name = "frmImport"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

' 2005-03-14, JFW, New commodity fields 120 marks and numbers and 1275 part number.



'---------------------------------------------------------------------------------------
' Procedure : cmdBrowse_Click()
' DateTime  : 3/25/2004
' Purpose   : Shows dialog to select Commodity file to import.
'---------------------------------------------------------------------------------------
'
Private Sub cmdBrowse_Click()
    dlgCommodity.ShowOpen
    txtImportFilename = dlgCommodity.FileName
End Sub
'---------------------------------------------------------------------------------------
' Procedure : cmdClose_Click()
' DateTime  : 3/25/2004
' Purpose   : Close button clicked, hide form
'---------------------------------------------------------------------------------------
'
Private Sub cmdClose_Click()
    Select Case Me.Caption
        Case "Import Addresses"
            With frmShip
                Call .LoadAddrLookupCombos(.cboCustID, .cboCustID, "CustID")
                Call .LoadAddrLookupCombos(.cboContact, .cboContact, "f12")
                Call .LoadAddrLookupCombos(.cboCompany, .cboCompany, "f11")
            End With
        Case "Import Alternate Return Addresses"
            Call LoadAddrIDCombo(frmSetup.cboAddrID, frmSetup.cboAddrID)
        Case "Import Commodities"
            Call frmShip.LoadCommodities
        Case "Import Departments"
            With frmShip
                Call .LoadDeptCombo(.cboDept)
            End With
        Case "Import Box Dimensions"
            Call LoadBoxDIMsCombos(frmShip.cboBoxName(0))
            Call LoadBoxDIMsCombos(frmShip.cboBoxName(1))
            Call LoadBoxDIMsCombos(frmMPS.cboBoxName)
    End Select
    
    Me.Hide
    lblStatus.Caption = "Idle"
    lblImported.Caption = ""
    lblErrors.Caption = ""
    txtImportFilename = ""
    optAppend = True
    
    frmShip.SetFocus
End Sub
'---------------------------------------------------------------------------------------
' Procedure : cmdImport_Click()
' DateTime  : 3/25/2004
' Purpose   : Import button clicked. Routine to import Commodities.
'---------------------------------------------------------------------------------------
'
Private Sub cmdImport_Click()
    Call ImportTable(Me.Caption)
End Sub
'---------------------------------------------------------------------------------------
' Procedure : ImportTable()
' DateTime  : 2/16/2005
' Purpose   : Calle sub to import specific table.
'---------------------------------------------------------------------------------------
'
Private Sub ImportTable(ByVal strCaption As String)

    Select Case strCaption
        Case "Import Addresses"
            Call ImportAddresses
        Case "Import Alternate Return Addresses"
            Call ImportAltReturnAddr
        Case "Import Commodities"
            Call ImportCommodities
        Case "Import Departments"
            Call ImportDepts
        Case "Import Box Dimensions"
            Call ImportDIMs
    End Select
End Sub
'---------------------------------------------------------------------------------------
' Procedure : ImportAddresses()
' DateTime  : 8/31/2004
' Purpose   : Import button clicked. Routine to import Commodities.
'---------------------------------------------------------------------------------------
'
Public Sub ImportAddresses()
    Dim strQuery As String
    Dim fsoTextFile As New FileSystemObject
    Dim tsoLine As TextStream
    Dim strLine As String
    Dim strFields() As String
    Dim intImported As Integer
    Dim intErrors As Integer
    Dim i As Integer
    
    On Error Resume Next
    'Check to see if file exists before loading
    If fsoTextFile.FileExists(txtImportFilename) Then
        Set tsoLine = fsoTextFile.OpenTextFile(txtImportFilename, ForReading)
    Else
        MsgBox "Import file not found!", vbExclamation, "Import Error"
        Exit Sub
    End If
    'If Overwrite selected, delete current commodities
    If optOverwrite Then
        strQuery = "DELETE * FROM AddressBook"
        g_connFSMSClient.Execute strQuery
    End If
        
    'Show status as importing
    lblStatus.Caption = "Importing..."
    'Initialize counters
    i = 0
    intErrors = 0
    intImported = 0
    'read each line in fiel and import
    Do Until tsoLine.AtEndOfStream
        
        i = i + 1
        strLine = tsoLine.ReadLine
        strFields = Split(strLine, ",")
        
        'Build query
        strQuery = "INSERT INTO AddressBook VALUES ("
        strQuery = strQuery + Replace(SingleQuotes(strFields(0)), Chr(34), "") + ","  'CustID
        strQuery = strQuery + Replace(SingleQuotes(strFields(1)), Chr(34), "") + ","  'f11 - Company
        strQuery = strQuery + Replace(SingleQuotes(strFields(2)), Chr(34), "") + ","  'f12 - Contact
        strQuery = strQuery + Replace(SingleQuotes(strFields(3)), Chr(34), "") + ","  'f13 - Addr1
        strQuery = strQuery + Replace(SingleQuotes(strFields(4)), Chr(34), "") + ","  'f14 - Addr2
        strQuery = strQuery + Replace(SingleQuotes(strFields(5)), Chr(34), "") + ","  'f15 - City
        strQuery = strQuery + Replace(SingleQuotes(strFields(6)), Chr(34), "") + ","  'f16 - State
        strQuery = strQuery + Replace(SingleQuotes(strFields(7)), Chr(34), "") + ","  'f17 - Zip
        strQuery = strQuery + Replace(SingleQuotes(strFields(8)), Chr(34), "") + ","  'f50 - Country Code
        strQuery = strQuery + Replace(SingleQuotes(strFields(9)), Chr(34), "") + ","  'f18 - Phone
        strQuery = strQuery + Replace(SingleQuotes(strFields(10)), Chr(34), "") + "," 'f23 - Payment Type
        strQuery = strQuery + Replace(SingleQuotes(strFields(11)), Chr(34), "") + "," 'f20 - Acct#
        strQuery = strQuery + Replace(SingleQuotes(strFields(12)), Chr(34), "") + "," 'f1202 - Email
        ' 2005-08-24, JFW, AddressBook EIN.
        strQuery = strQuery + Replace(SingleQuotes(strFields(13)), Chr(34), "") + ")" 'f118 - EIN
        'Execute the query
        g_connFSMSClient.Execute strQuery
        
        'If there's an error, increment error count and save to file
        If Err.Description <> "" Then
            intErrors = intErrors + 1
            lblErrors.Caption = Str(intErrors)
            Open App.Path & "\AddressImportErrors_" & Format(Date, "YYYYMMDD") & ".txt" For Append As #1
            'Save record #, error description, and line data to file.
            Print #1, "Record #" + Str(i) + " Error:" + Err.Description + "," + strLine
            Close #1
            'Clear error
            Err.Clear
        'Else increment Imported count and display
        Else
            intImported = intImported + 1
            lblImported.Caption = Str(intImported)
        End If
    Loop
    'Update status
    lblStatus.Caption = "Complete!"
    
    'If there were errors display path and filename containing error info
    If intErrors > 0 Then
        MsgBox "Errors saved to " & App.Path & "\AddressImportErrors_" & Format(Date, "YYYYMMDD") & ".txt"
    End If

End Sub
'---------------------------------------------------------------------------------------
' Procedure : ImportAltReturnAddr()
' DateTime  : 8/31/2004
' Purpose   : Import button clicked. Routine to import Commodities.
'---------------------------------------------------------------------------------------
'
Public Sub ImportAltReturnAddr()
    Dim strQuery As String
    Dim fsoTextFile As New FileSystemObject
    Dim tsoLine As TextStream
    Dim strLine As String
    Dim strFields() As String
    Dim intImported As Integer
    Dim intErrors As Integer
    Dim i As Integer
    
    On Error Resume Next
    'Check to see if file exists before loading
    If fsoTextFile.FileExists(txtImportFilename) Then
        Set tsoLine = fsoTextFile.OpenTextFile(txtImportFilename, ForReading)
    Else
        MsgBox "Import file not found!", vbExclamation, "Import Error"
        Exit Sub
    End If
    'If Overwrite selected, delete current commodities
    If optOverwrite Then
        strQuery = "DELETE * FROM AltReturnAddr"
        g_connFSMSClient.Execute strQuery
    End If
        
    'Show status as importing
    lblStatus.Caption = "Importing..."
    'Initialize counters
    i = 0
    intErrors = 0
    intImported = 0
    'read each line in fiel and import
    Do Until tsoLine.AtEndOfStream
        
        i = i + 1
        strLine = tsoLine.ReadLine
        strFields = Split(strLine, ",")
        
        'Build query
        strQuery = "INSERT INTO AltReturnAddr VALUES ("
        strQuery = strQuery + Replace(SingleQuotes(strFields(0)), Chr(34), "") + ","  'AddrID
        strQuery = strQuery + Replace(SingleQuotes(strFields(1)), Chr(34), "") + ","  'f1485 - Contact
        strQuery = strQuery + Replace(SingleQuotes(strFields(2)), Chr(34), "") + ","  'f1486 - Company
        strQuery = strQuery + Replace(SingleQuotes(strFields(3)), Chr(34), "") + ","  'f1487 - Addr1
        strQuery = strQuery + Replace(SingleQuotes(strFields(4)), Chr(34), "") + ","  'f1488 - Addr2
        strQuery = strQuery + Replace(SingleQuotes(strFields(5)), Chr(34), "") + ","  'f1489 - City
        strQuery = strQuery + Replace(SingleQuotes(strFields(6)), Chr(34), "") + ","  'f1490 - State
        strQuery = strQuery + Replace(SingleQuotes(strFields(7)), Chr(34), "") + ","  'f1491 - Zip
        strQuery = strQuery + Replace(SingleQuotes(strFields(8)), Chr(34), "") + ","  'f1585 - Country Code
        strQuery = strQuery + Replace(SingleQuotes(strFields(9)), Chr(34), "") + ")"  'f1492 - Phone
        'Execute the query
        g_connFSMSClient.Execute strQuery
        
        'If there's an error, increment error count and save to file
        If Err.Description <> "" Then
            intErrors = intErrors + 1
            lblErrors.Caption = Str(intErrors)
            Open App.Path & "\AltReturnAddrImportErrors_" & Format(Date, "YYYYMMDD") & ".txt" For Append As #1
            'Save record #, error description, and line data to file.
            Print #1, "Record #" + Str(i) + " Error:" + Err.Description + "," + strLine
            Close #1
            'Clear error
            Err.Clear
        'Else increment Imported count and display
        Else
            intImported = intImported + 1
            lblImported.Caption = Str(intImported)
        End If
    Loop
    'Update status
    lblStatus.Caption = "Complete!"
    
    'If there were errors display path and filename containing error info
    If intErrors > 0 Then
        MsgBox "Errors saved to " & App.Path & "\AltReturnAddrImportErrors_" & Format(Date, "YYYYMMDD") & ".txt"
    End If

End Sub
'---------------------------------------------------------------------------------------
' Procedure : ImportCommodities()
' DateTime  : 3/25/2004
' Purpose   : Import button clicked. Routine to import Commodities.
'---------------------------------------------------------------------------------------
'
Public Sub ImportCommodities()
    Dim strQuery As String
    Dim fsoTextFile As New FileSystemObject
    Dim tsoLine As TextStream
    Dim strLine As String
    Dim strFields() As String
    Dim intImported As Integer
    Dim intErrors As Integer
    Dim i As Integer
    
    On Error Resume Next
    'Check to see if file exists before loading
    If fsoTextFile.FileExists(txtImportFilename) Then
        Set tsoLine = fsoTextFile.OpenTextFile(txtImportFilename, ForReading)
    Else
        MsgBox "Import file not found!", vbExclamation, "Import Error"
        Exit Sub
    End If
    'If Overwrite selected, delete current commodities
    If optOverwrite Then
        strQuery = "DELETE * FROM Commodity"
        g_connFSMSClient.Execute strQuery
    End If
        
    'Show status as importing
    lblStatus.Caption = "Importing..."
    'Initialize counters
    i = 0
    intErrors = 0
    intImported = 0
    'read each line in fiel and import
    Do Until tsoLine.AtEndOfStream
        
        i = i + 1
        strLine = tsoLine.ReadLine
        strFields = Split(strLine, ",")
        
        'Build query
        strQuery = "INSERT INTO Commodity VALUES ("
        strQuery = strQuery + Replace(SingleQuotes(strFields(0)), Chr(34), "") + ","  'CommodityID
        strQuery = strQuery + Replace(SingleQuotes(strFields(1)), Chr(34), "") + ","  'CommodityWgt
        strQuery = strQuery + Replace(SingleQuotes(strFields(2)), Chr(34), "") + ","  'g_str79 - Description
        strQuery = strQuery + Replace(SingleQuotes(strFields(3)), Chr(34), "") + ","  'g_str80 - Country of Manu
        strQuery = strQuery + Replace(SingleQuotes(strFields(4)), Chr(34), "") + ","  'g_str81 - Harmonized Code
        strQuery = strQuery + Replace(SingleQuotes(strFields(5)), Chr(34), "") + ","  'g_str83 - Export License #
        strQuery = strQuery + Replace(SingleQuotes(strFields(6)), Chr(34), "") + ","  'g_str84 - License Expiration Date
        strQuery = strQuery + Replace(SingleQuotes(strFields(7)), Chr(34), "") + ","  'g_str120 - Marks and numbers
        strQuery = strQuery + Replace(SingleQuotes(strFields(8)), Chr(34), "") + ","  'g_str414 - Unit of Measure
        strQuery = strQuery + Replace(SingleQuotes(strFields(9)), Chr(34), "") + ","  'g_str1030 - Commodity Unit Value
        strQuery = strQuery + Replace(SingleQuotes(strFields(10)), Chr(34), "") + ")"  'g_str1275 - Part number
        'Execute the query
        g_connFSMSClient.Execute strQuery
        
        'If there's an error, increment error count and save to file
        If Err.Description <> "" Then
            intErrors = intErrors + 1
            lblErrors.Caption = Str(intErrors)
            Open App.Path & "\CommodityImportErrors_" & Format(Date, "YYYYMMDD") & ".txt" For Append As #1
            'Save record #, error description, and line data to file.
            Print #1, "Record #" + Str(i) + " Error:" + Err.Description + "," + strLine
            Close #1
            'Clear error
            Err.Clear
        'Else increment Imported count and display
        Else
            intImported = intImported + 1
            lblImported.Caption = Str(intImported)
        End If
    Loop
    'Update status
    lblStatus.Caption = "Complete!"
    
    'If there were errors display path and filename containing error info
    If intErrors > 0 Then
        MsgBox "Errors saved to " & App.Path & "\CommodityImportErrors_" & Format(Date, "YYYYMMDD") & ".txt"
    End If

End Sub
'---------------------------------------------------------------------------------------
' Procedure : ImportDepts()
' DateTime  : 2/10/2005
' Purpose   : Import Depts
'---------------------------------------------------------------------------------------
'
Public Sub ImportDepts()
    Dim strQuery As String
    Dim fsoTextFile As New FileSystemObject
    Dim tsoLine As TextStream
    Dim strLine As String
    Dim intImported As Integer
    Dim intErrors As Integer
    Dim i As Integer
    
    On Error Resume Next
    'Check to see if file exists before loading
    If fsoTextFile.FileExists(txtImportFilename) Then
        Set tsoLine = fsoTextFile.OpenTextFile(txtImportFilename, ForReading)
    Else
        MsgBox "Import file not found!", vbExclamation, "Import Error"
        Exit Sub
    End If
    'If Overwrite selected, delete current commodities
    If optOverwrite Then
        strQuery = "DELETE * FROM Departments"
        g_connFSMSClient.Execute strQuery
    End If
        
    'Show status as importing
    lblStatus.Caption = "Importing..."
    'Initialize counters
    i = 0
    intErrors = 0
    intImported = 0
    'read each line in fiel and import
    Do Until tsoLine.AtEndOfStream
        
        i = i + 1
        strLine = tsoLine.ReadLine
        
        'Build query
        strQuery = "INSERT INTO Departments VALUES ("
        strQuery = strQuery + Replace(SingleQuotes(strLine), Chr(34), "") + ")"
        'Execute the query
        g_connFSMSClient.Execute strQuery
        
        'If there's an error, increment error count and save to file
        If Err.Description <> "" Then
            intErrors = intErrors + 1
            lblErrors.Caption = Str(intErrors)
            Open App.Path & "\DeptsImportErrors_" & Format(Date, "YYYYMMDD") & ".txt" For Append As #1
            'Save record #, error description, and line data to file.
            Print #1, "Record #" + Str(i) + " Error:" + Err.Description + "," + strLine
            Close #1
            'Clear error
            Err.Clear
        'Else increment Imported count and display
        Else
            intImported = intImported + 1
            lblImported.Caption = Str(intImported)
        End If
    Loop
    'Update status
    lblStatus.Caption = "Complete!"
    
    'If there were errors display path and filename containing error info
    If intErrors > 0 Then
        MsgBox "Errors saved to " & App.Path & "\DeptsImportErrors_" & Format(Date, "YYYYMMDD") & ".txt"
    End If

End Sub
'---------------------------------------------------------------------------------------
' Procedure : ImportDIMs()
' DateTime  : 4/9/2004
' Purpose   : Import button clicked. Routine to import Box DIMs then populate Box Name
'             combos on frmShip.
'---------------------------------------------------------------------------------------
'
Public Sub ImportDIMs()
    Dim strQuery As String
    Dim fsoTextFile As New FileSystemObject
    Dim tsoLine As TextStream
    Dim strLine As String
    Dim strFields() As String
    Dim intImported As Integer
    Dim intErrors As Integer
    Dim i As Integer
    
    On Error Resume Next
    'Check to see if file exists before loading
    If fsoTextFile.FileExists(txtImportFilename) Then
        Set tsoLine = fsoTextFile.OpenTextFile(txtImportFilename, ForReading)
    Else
        MsgBox "Import file not found!", vbExclamation, "Import Error"
        Exit Sub
    End If
    'If Overwrite selected, delete current commodities
    If optOverwrite Then
        strQuery = "DELETE * FROM Dimensions"
        g_connFSMSClient.Execute strQuery
    End If
        
    'Show status as importing
    lblStatus.Caption = "Importing..."
    'Initialize counters
    i = 0
    intErrors = 0
    intImported = 0
    'read each line in fiel and import
    Do Until tsoLine.AtEndOfStream
        
        i = i + 1
        strLine = tsoLine.ReadLine
        strFields = Split(strLine, ",")
        
        'Build query
        strQuery = "INSERT INTO Dimensions VALUES ("
        strQuery = strQuery + Replace(SingleQuotes(strFields(0)), Chr(34), "") + ","  'Box Name
        strQuery = strQuery + Replace(SingleQuotes(strFields(1)), Chr(34), "") + ","  'f57
        strQuery = strQuery + Replace(SingleQuotes(strFields(2)), Chr(34), "") + ","  'f58
        strQuery = strQuery + Replace(SingleQuotes(strFields(3)), Chr(34), "") + ")"  'f59
        'Execute the query
        g_connFSMSClient.Execute strQuery
        
        'If there's an error, increment error count and save to file
        If Err.Description <> "" Then
            intErrors = intErrors + 1
            lblErrors.Caption = Str(intErrors)
            Open App.Path & "\BoxDIMsImportErrors_" & Format(Date, "YYYYMMDD") & ".txt" For Append As #1
            'Save record #, error description, and line data to file.
            Print #1, "Record #" + Str(i) + " Error:" + Err.Description + "," + strLine
            Close #1
            'Clear error
            Err.Clear
        'Else increment Imported count and display
        Else
            intImported = intImported + 1
            lblImported.Caption = Str(intImported)
        End If
    Loop
    'Update status
    lblStatus.Caption = "Complete!"
    
    'If there were errors display path and filename containing error info
    If intErrors > 0 Then
        MsgBox "Errors saved to " & App.Path & "\DIMsImportErrors_" & Format(Date, "YYYYMMDD") & ".txt"
    End If

End Sub

Private Sub Form_Activate()
    optAppend.SetFocus
End Sub

'---------------------------------------------------------------------------------------
' Procedure : Form_KeyDown()
' DateTime  : 2/17/2005
' Purpose   : Enter key pressed sends a TAB to move to next field
'---------------------------------------------------------------------------------------
'
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If Not TypeOf Me.ActiveControl Is CommandButton Then
        If Shift = 0 And KeyCode = 13 Then
            SendKeys "{TAB}"
        End If
    End If
End Sub
'---------------------------------------------------------------------------------------
' Procedure : Form_Load()
' DateTime  : 3/25/2004
' Purpose   : Set Append as default import method and set Status caption to Idle.
'---------------------------------------------------------------------------------------
'
Private Sub Form_Load()
    optAppend = True
    lblStatus.Caption = "Idle"
    cmdImport.Enabled = False
End Sub

Private Sub txtImportFilename_Change()
    If txtImportFilename <> "" Then
        cmdImport.Enabled = True
    Else
        cmdImport.Enabled = False
    End If
End Sub
